<?php 
	include_once('Base.class.php');
	class bubSort extends Base{
		static function bubbleSort($arr){
			$len = count($arr);
			for ($i=0; $i <$len ; $i++) { 
				for ($j=0; $j <($len-$i) ; $j++) {
					//防止Undefined offset: <索引>错误 
					if (isset($arr["$j"+1])) {
						//降序 (注意一定是大减小,反之GG)
						if($arr["$j"]<$arr["$j"+1]){
							$arr["$j"] = $arr["$j"+1] - $arr["$j"];
							$arr["$j"+1] = $arr["$j"+1] - $arr["$j"];
							$arr["$j"] = $arr["$j"+1] + $arr["$j"];
						}
					}
				}
			}
			return $arr;
		}
	}
	$arr = array(2,35,57,98,32,46);
	$base = new Base();
	$base->pri(bubSort::bubbleSort($arr));
 ?>